package Util;

import java.io.Serializable;
import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import Model.HoaDon;




public class HoaDonDataModel extends ListDataModel<HoaDon> implements SelectableDataModel<HoaDon>,Serializable{
	
	public HoaDonDataModel(){
		
	}
	public HoaDonDataModel(List<HoaDon> dshd){
		super(dshd);
	}
	@Override
	public HoaDon getRowData(String rowkey) {
		Integer irowkey = Integer.parseInt(rowkey);
List<HoaDon> hoadons = (List<HoaDon>) getWrappedData();  
        
        for(HoaDon hoadon : hoadons) {  
            if(hoadon.getMahoadon().equals(irowkey))  
                return hoadon;  
        }  
 
        return null; 
		
	}

	@Override
	public Object getRowKey(HoaDon hoadon) {
		
		return hoadon.getMahoadon();
	}

}
